<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/static/element/index.css}"/>
</head>
<body>
<div id="app">
    <template>
        <el-form :model="formData" ref="formData" :rules="rules" label-width="100px" style="margin-top: 5%">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="岗位编码" prop="postCode">
                        <el-input size="small" v-model="formData.postCode"></el-input>
                    </el-form-item>
                </el-col>

                <el-col :span="11">
                    <el-form-item label="岗位名称" prop="postName">
                        <el-input size="small" v-model="formData.postName"></el-input>
                    </el-form-item>
                </el-col>

            </el-row>

            <el-row>
                <el-col :span="12">
                    <el-form-item label="备注" prop="remark">
                        <el-input size="small" type="textarea" v-model="formData.remark"
                                  @keyup.enter.native="handleSubmit"></el-input>
                    </el-form-item>
                </el-col>


            </el-row>
        </el-form>
        <div style="text-align: center;margin-top: 5%">
            <el-button size="small" @click="closePage">取 消</el-button>
            <el-button size="small" type="primary" @click="handleSubmit">确 定</el-button>
        </div>
    </template>
</div>
</body>
<script th:src="@{/static/js/axios.min.js}"></script>
<script th:src="@{/static/js/request.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/api/post.js}"></script>
<script th:src="@{/static/js/vue.min.js}"></script>
<script th:src="@{/static/element/index.js}"></script>
<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/layer/layer.js}"></script>
<script>
    let id = getQueryString("id");
    new Vue({
        el: '#app',
        data() {
            return {
                formData: {
                    id: '',
                    postName: '',
                    postCode: '',
                    remark: ''
                },
                rules: {
                    postName: [
                        {required: true, message: '请输入岗位名称', trigger: 'blur'},
                    ],
                    postCode: [
                        {required: true, message: '请输入岗位编码', trigger: 'blur'},
                    ]
                }
            }
        },
        created() {
            if (id) {
                detail(id).then((res) => {
                    if (res.code === '200') {
                        this.formData = res.data
                    }
                });
            } else {
                this.formData = {}
            }

        },
        methods: {
            handleSubmit() {
                if (id) {
                    addOrUpdate('/sys/post/update', this);
                } else {
                    addOrUpdate('/sys/post/add', this);
                }
            }
        }
    });
</script>
</html>
